<template>
  <div class="hello">
    <!--
     span: 24以下的任意数字
     gutter : 两个栏之间的间隔，默认是0
     :offset : 分栏偏移，注意，分栏便宜的大小 也在24之内
     -->
    <!--<el-row :gutter="20">-->

      <!--<el-col :span="1"><div class="grid-content bg-purple-dark"></div></el-col>-->
      <!--<el-col :span="16" :offset="6"><div class="grid-content bg-purple-dark"></div></el-col>-->
    <!--</el-row>-->

    <el-form  label-width="80px" :model="user">
      <el-form-item label="用户名">
        <el-input v-model="user.userName"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input v-model="user.password"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">立即创建</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: 'HelloWorld',
  data () {
    return {
      msg: 'Welcome to Your Vue.js App',
      user:{},

    }
  },
  methods:{
    onSubmit:function () {
      this.$axios.post("/user/login",this.user).then(res=>{
          alert(res.data.msg);
          if (res.data.code==1){
            //将后端的无状态token存储在cookie中
            this.$cookie.set("token",res.data.data);
          //跳转页面到index页面
            this.$router.push("/index")
          }
      })
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style>
  .el-row {
    margin-bottom: 20px;
  &:last-child {
     margin-bottom: 0;
   }
  }
  .el-col {
    border-radius: 4px;
  }
  .bg-purple-dark {
    background: #99a9bf;
  }
  .bg-purple {
    background: #d3dce6;
  }
  .bg-purple-light {
    background: #e5e9f2;
  }
  .grid-content {
    border-radius: 4px;
    min-height: 36px;
  }
  .row-bg {
    padding: 10px 0;
    background-color: #f9fafc;
  }
</style>
